home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / amiex / KLR_ChatSRC.lha / Chat-O-Meter.C < prev    next >
C/C++ Source or Header  |  1995-06-29  |  20KB  |  622 lines

  1. #define COM_REGISTER
  2.  
  3. #include "Chat-O-Meter.H"
  4.  
  5. #define ERROR 1
  6. #define BULL  2
  7.  
  8. //#define DEBUG
  9.  
  10. UBYTE VER[]="$VER: Chat-O-Meter 2.3.0 "__AMIGADATE__;
  11. UBYTE ErrStr[] = "Chat-O-Meter ERROR! Could not %s";
  12.  
  13. struct    COMDATA        *com_ptr=NULL;
  14. struct    CHATTOP        *chat_ptr=NULL;
  15. struct    TODAY_DATA    *td_ptr=NULL;
  16.  
  17. void main ( int argc , char *argv[] )
  18. {
  19.     char    temp[ 200 ], temp2[ 200 ], filename[ 50 ];
  20.  
  21.     char    bulletin[ 200 ];
  22.  
  23.     int    i, j;
  24.  
  25.     ULONG    t_begin , t_end;
  26.  
  27.     BOOL    EndChat    = FALSE,
  28.             ShowAsk    = TRUE,
  29.             Trunc      = TRUE,
  30.             DoTopTen   = TRUE,
  31.             HideChat   = FALSE,
  32.             DoToday    = TRUE,
  33.             New_Record = FALSE,
  34.             Quiet      = FALSE,
  35.             //BackUp     = FALSE,
  36.             DoLog      = TRUE;
  37.  
  38.     UBYTE TimeFile[]  = "T:CoM_StartChat.Node";
  39.     UBYTE    DataFile[]  = "PROGDIR:Chat-O-Meter.Data";
  40.     //UBYTE    BackUpFile[]= "PROGDIR:Chat-O-Meter.Last";
  41.  
  42.     struct Library    *IconBase;
  43.     struct DiskObject *dobj;
  44.     char   *tooltype, **toolarray;
  45.  
  46.     FILE    *fptr;
  47.  
  48.     Register( atoi( argv[ 1 ] ) );
  49.  
  50.     // Allocate memory for the two structures
  51.     com_ptr = AllocVec( sizeof( struct COMDATA ) , MEMF_PUBLIC|MEMF_CLEAR );
  52.     chat_ptr = AllocVec( sizeof( struct CHATTOP ) , MEMF_PUBLIC|MEMF_CLEAR );
  53.     td_ptr = AllocVec( sizeof( struct TODAY_DATA ) , MEMF_PUBLIC|MEMF_CLEAR );
  54.     if ( com_ptr == NULL || chat_ptr == NULL || td_ptr == NULL )
  55.     {
  56.         sprintf( temp , ErrStr , "allocate memory." );
  57.         sm( temp , 1 );
  58.         enddoor( FALSE );
  59.     }
  60.  
  61.     // Trace the command icon
  62.     getuserstring( temp2 , BB_MAINLINE );
  63.     LocateCommandIcon( temp , temp2 );
  64.  
  65.     // Open icon library and read the icon's tooltypes
  66.     IconBase = OpenLibrary("icon.library", 0L    );
  67.     if ( IconBase )
  68.     {
  69.         dobj = GetDiskObject( temp );
  70.         if ( dobj )
  71.         {
  72.             toolarray = (char **) dobj->do_ToolTypes;
  73.             if ( tooltype = FindToolType( toolarray , "CHAT_END" ) )
  74.                 EndChat = TRUE;    
  75.             if ( tooltype = FindToolType( toolarray , "DONT_ASK" ) )
  76.                 ShowAsk = FALSE;    
  77.             if ( tooltype = FindToolType( toolarray , "DONT_TRUNC" ) )
  78.                 Trunc = FALSE;
  79.             if ( tooltype = FindToolType( toolarray , "NO_USERFILE" ) )
  80.                 DoTopTen = FALSE;
  81.             if ( tooltype = FindToolType( toolarray , "HIDE_CHAT" ) )
  82.                 HideChat = TRUE;
  83.             if ( tooltype = FindToolType( toolarray , "NO_DAY_RECORD" ) )
  84.                 DoToday = FALSE;
  85.             if ( tooltype = FindToolType( toolarray , "QUIET" ) )
  86.                 Quiet = TRUE;
  87.             /**********
  88.             if ( tooltype = FindToolType( toolarray , "BACKUP" ) )
  89.                 BackUp = TRUE;
  90.             **********/
  91.             if ( tooltype = FindToolType( toolarray , "NO_LOG" ) )
  92.                 DoLog = FALSE;
  93.             if ( tooltype = FindToolType( toolarray , "BULLETIN" ) )
  94.                 strcpy( bulletin , tooltype );
  95.             else
  96.             {
  97.                 if ( EndChat )
  98.                 {
  99.                     sprintf( temp , ErrStr , "find \"BULLETIN\" tooltype." );
  100.                     sm( temp , 1 );
  101.                     enddoor( FALSE );
  102.                 }
  103.             }
  104.             FreeDiskObject( dobj );
  105.         }
  106.         else
  107.         {
  108.             sprintf( temp , ErrStr , "lock command icon." );
  109.             sm( temp , 1 );
  110.             enddoor( FALSE );
  111.         }
  112.         CloseLibrary( IconBase );
  113.     }
  114.     else
  115.     {
  116.         sprintf( temp , ErrStr , "open icon library." );
  117.         sm( temp , 1 );
  118.         enddoor( FALSE );
  119.     }
  120.  
  121.     // What's the time?
  122.     time( (time_t *) &t_end);
  123.  
  124.     getuserstring( temp , BB_NODEID );
  125.     temp[ 2 ] = 0x00;
  126.     sprintf( filename , "%s_%s" , TimeFile , temp );
  127.  
  128.     if ( ! EndChat )
  129.     {
  130.         if ( ! HideChat )
  131.         {
  132.             // Make known that user is chatting
  133.             putuserstring( "17" , ENVSTAT );
  134.         }
  135.  
  136.         /* OPENING TEMP-FILE TO WRITE DATE/TIME */
  137.         if ( fptr = fopen( filename , "w" ) )
  138.         {
  139.             fprintf( fptr , "%ld\n" , t_end );
  140.             fclose( fptr );
  141.         }
  142.         else
  143.         {
  144.             sprintf( temp , ErrStr , "save starting time." );
  145.             sm( temp ,1 );
  146.         }
  147.         enddoor( FALSE );
  148.     }
  149.  
  150.     // This point will only be reached if the chat has ended
  151.     if ( access( DataFile , F_OK ) )
  152.     {
  153.         // Not found
  154.         if ( fptr = fopen( DataFile , "w" ) )
  155.         {
  156.             com_ptr->Chats = 0;
  157.             com_ptr->TimeChatted = 0;
  158.             for ( i = 0 ; i < 10 ; i ++ )
  159.             {
  160.                 com_ptr->Time[ i ] = 0;
  161.                 com_ptr->Date[ i ] = 0;
  162.                 com_ptr->User[ i ][ 0 ] = '-';
  163.                 com_ptr->User[ i ][ 1 ] = 0x00;
  164.             }
  165.             fwrite( com_ptr , sizeof( struct COMDATA ) , 1 , fptr );
  166.             fclose( fptr );
  167.         }
  168.         else
  169.             enddoor( ERROR );
  170.     }
  171.  
  172.     if ( fptr = fopen( filename , "r" ) )
  173.     {
  174.         fgets( temp2 , sizeof( temp2 ) , fptr );
  175.         t_begin = atol( temp2 );
  176.         t_end -= t_begin;    // Number of seconds chat lasted
  177.         fclose( fptr );
  178.  
  179.         /* UPDATE TODAY FiLE */
  180.         if ( DoToday )
  181.             New_Record = Today( t_end );
  182.  
  183.         /* UPDATE USER FiLE */
  184.         if ( DoTopTen )
  185.             TopTen( t_end );
  186.  
  187.         /* Update Log file */
  188.         if ( DoLog )
  189.             LogChat( t_begin, t_end );
  190.  
  191.         if ( fptr = fopen( DataFile , "r" ) )
  192.         {
  193.             fread( com_ptr , sizeof( struct COMDATA ) , 1 , fptr );
  194.             fclose( fptr );
  195.  
  196.             /************ 
  197.             if ( BackUp )
  198.             {
  199.                 if ( fptr = fopen( BackUpFile , "w" ) )
  200.                 {
  201.                     fwrite( com_ptr , sizeof( struct COMDATA ) , 1 , fptr );
  202.                     fclose( fptr );
  203.                 }
  204.                 else
  205.                 {
  206.                     sprintf( temp , ErrStr , "write backup." );
  207.                     sm( temp , 1 );
  208.                 }
  209.             }
  210.             ************/
  211.  
  212.             com_ptr->TimeChatted += t_end;
  213.             com_ptr->Chats++;
  214.  
  215.             i = RecordTime( t_end );
  216.  
  217.             if ( i != -1 )
  218.             {
  219.                 // Make room for new time in list
  220.                 for ( j = 10 ; j > ( i + 1 ) ; j -- )
  221.                 {
  222.                     com_ptr->Time[ j - 1 ] = com_ptr->Time[ j - 2 ];
  223.                     com_ptr->Date[ j - 1 ] = com_ptr->Date[ j - 2 ];
  224.                     strcpy( com_ptr->User[ j - 1 ] , com_ptr->User[ j -2 ] );
  225.                 }
  226.  
  227.                 com_ptr->Time[ i ] = t_end;
  228.  
  229.                 #ifdef DEBUG
  230.                 co( "Pick up user's name\n\r" , 0 );
  231.                 #endif
  232.  
  233.                 // Pick up user name, shorten it to 20 chars
  234.                 getuserstring( temp , DT_NAME );
  235.                 temp[ 20 ] = 0x00;
  236.                 strcpy( com_ptr->User[ i ] , temp );
  237.  
  238.                 #ifdef DEBUG
  239.                 co( "Picking up current time.\n\r" , 0 );
  240.                 #endif
  241.                 // What's the current time?
  242.                 time( (time_t *) &t_begin );
  243.                 com_ptr->Date[ i ] = t_begin;
  244.             }
  245.             // Save the new stats
  246.             if ( fptr = fopen( DataFile , "w" ) )
  247.             {
  248.                 fwrite( com_ptr , sizeof( struct COMDATA ) , 1 , fptr );
  249.                 fclose( fptr );
  250.             }
  251.             else
  252.                 enddoor( ERROR );
  253.  
  254.             // Create the bulletin
  255.             if ( fptr = fopen( bulletin , "w" ) )
  256.                 CreateBulletin( fptr , bulletin , Trunc , Quiet , DoToday );
  257.             else
  258.                 enddoor( BULL );
  259.  
  260.             // Present the end result
  261.             if ( ! Quiet )
  262.                 Record( t_end , i + 1 , bulletin , ShowAsk , DoTopTen , DoToday , New_Record );
  263.  
  264.             remove( filename );
  265.         }
  266.         else
  267.             enddoor( ERROR );
  268.     }
  269.     else
  270.         enddoor( ERROR );
  271.  
  272.     enddoor( FALSE );
  273. }
  274.  
  275. void enddoor ( int RC )
  276. {
  277.     if ( RC )
  278.         sm( "Chat-O-Meter ERROR! " , 0 );
  279.  
  280.     if ( RC == ERROR )
  281.         sm( "Couldn't open data file!" , 1 );
  282.  
  283.     if ( RC == BULL )
  284.         sm( "Couldn't write bulletin!" , 1 );
  285.  
  286.     if ( td_ptr )
  287.         FreeVec( td_ptr );
  288.  
  289.     if ( com_ptr )
  290.         FreeVec( com_ptr );
  291.  
  292.     if ( chat_ptr )
  293.         FreeVec( chat_ptr );
  294.  
  295.     ShutDown();
  296.     end();
  297. }
  298.  
  299. void LastCommand ( void )
  300. {}
  301.  
  302. void end ( void )
  303. {
  304.     exit ( 0 );
  305. }
  306.  
  307. void LocateCommandIcon( char *output , char *cmd_name )
  308. {
  309.     char    temp[ 200 ];
  310.     int    i;
  311.     
  312.     sprintf( temp , "BBS:Commands/SYSCmd/%s.info" , cmd_name );
  313.     if ( access( temp , F_OK ) )
  314.     {
  315.         // Not found
  316.         getuserstring( temp , BB_CONFNUM );
  317.         i = atoi( temp ) + 1;
  318.         sprintf( temp , "BBS:Commands/Conf%dCmd/%s.info" , i , cmd_name );
  319.         if ( access( temp , F_OK ) )
  320.         {
  321.             // Not found
  322.             getuserstring( temp , BB_NODEID );
  323.             sprintf( temp , "BBS:Commands/Node%sCmd/%s.info" , temp , cmd_name );
  324.             if ( access( temp , F_OK ) )
  325.             {
  326.                 // Not found
  327.                 sprintf( temp , "BBS:Commands/BBSCmd/%s.info" , cmd_name );
  328.                 if ( access( temp , F_OK ) )
  329.                 {
  330.                     // Not found
  331.                     //strcpy( output, "Could not find it!" );
  332.                      output[ 0 ] = 0x00;
  333.                 }
  334.                 else
  335.                     sprintf( output, "BBS:Commands/BBSCmd/%s" , cmd_name );
  336.             }
  337.             else
  338.                 sprintf( output , "BBS:Commands/Node%sCmd/%s" , temp , cmd_name );
  339.         }
  340.         else
  341.             sprintf( output , "BBS:Commands/Conf%dCmd/%s" , i , cmd_name );
  342.     }
  343.     else
  344.         sprintf( output , "BBS:Commands/SYSCmd/%s" , cmd_name );
  345. }
  346.  
  347. int RecordTime( ULONG t )
  348. {
  349.     int i;
  350.     
  351.     for ( i = 0 ; i <= 9 ; i ++ )
  352.     {
  353.         if ( t > com_ptr->Time[ i ] )
  354.             return( i );
  355.     }
  356.     return( -1 );
  357. }
  358.  
  359. void Record( ULONG t , int Position , char *bulletin , BOOL ShowAsk , BOOL DoTopTen , BOOL DoToday , BOOL New_Record )
  360. {
  361.     char    temp[ 400 ];
  362.     int    hours, mins, secs;
  363.     int    t_hours, t_mins, t_secs;
  364.     int    td_hours, td_mins , td_secs;
  365.  
  366.     /* Convert all seconds to hours, minutes and seconds */
  367.     SecsToHours( t , &hours , &mins , &secs );
  368.     SecsToHours( com_ptr->TimeChatted , &t_hours , &t_mins , &t_secs );
  369.     SecsToHours( td_ptr -> tt_Time , &td_hours , &td_mins , &td_secs );
  370.  
  371.     sm( "\n\r :                                                                         :" , 1 );
  372.     sm( "-O-------------------------------------------------------------------------O-" , 1 );
  373.     sm( " :  /X MYSTiC       Chat-O-Meter v2.3  by  KiLLraVeN/MYSTiC     /X MYSTiC  :" , 1 );
  374.     sm( " ¡                                                                         ." , 1 );
  375.     if ( DoToday )
  376.         sprintf( temp , " :  tIME%2.2d:%2.2d:%2.2d cHAT #:%6d tODAY%2.2d:%2.2d:%2.2d oVERALL%4.4d:%2.2d:%2.2d ¡" , hours , mins , secs , com_ptr->Chats , td_hours , td_mins , td_secs , t_hours , t_mins , t_secs );
  377.     else
  378.         sprintf( temp , " :    tHIS cHAT%2d:%2.2d:%2.2d oVERALL tIME%4.4d:%2.2d:%2.2d cHAT #%-8ld    ¡" , hours , mins , secs , t_hours , t_mins , t_secs , com_ptr->Chats );
  379.     sm( temp , 1 );
  380.  
  381.     if ( DoTopTen )
  382.     {
  383.         SecsToHours( chat_ptr->Time , &t_hours , &t_mins , &t_secs );
  384.         sprintf( temp , " .            pRIVATE sCORE%4.4ld:%2.2d:%2.2d pRIVATE chAT #%-6d           :" , t_hours , t_mins , t_secs , chat_ptr->Chats );
  385.         sm( temp , 1 );
  386.     }
  387.  
  388.     sm( " .                                                                         |" , 1 );
  389.  
  390.     switch ( Position )
  391.     {
  392.         case    0: 
  393.             sm( " :   sORRY dUDE, nO Chat-O-Meter tOP tIME tODAY, tRY aGAIN sOON, oKAY?!    :" , 1 );
  394.             break;
  395.             
  396.         case  1:
  397.             sm( " :    wOW! yOU aRE nOW tHE #1 cHATTER oN tHIS bOARD! cONGRATULATIONS!!!    :" , 1 );
  398.             break;
  399.  
  400.         case  2:
  401.             sm( " :   yOU aRE nOW tHE #2 cHATTER! tHAT'S a rIGHTEOUS aCT dUDE! gO fOR #1!   :" , 1 );
  402.             break;
  403.  
  404.         case    3:
  405.             sm( " :   bRONZE fOR yOU iN tHE Chat-O-Meter! yOUR nAME wILL bE rEMEMBERED!!    :" , 1 );
  406.             break;
  407.  
  408.         default:
  409.             sprintf( temp , " :  yOU mADE iT tO pOSITION %2.2d IN tHE Chat-O-MetertRY tO gET tO tHE tOP! :" , Position );
  410.             sm( temp , 1 );
  411.             break;
  412.     }
  413.  
  414.     sm( "-O-------------------------------------------------------------------------O-" , 1 );
  415.  
  416.     if ( New_Record )
  417.     {
  418.         sm( " :                    ATTENTiON! NEW DAY RECORD DETECTED!                  :" , 1 );
  419.         sm( "-O-------------------------------------------------------------------------O-" , 1 );
  420.     }
  421.  
  422.     sm( " :                                                                         :" , 1 );
  423.  
  424.     if ( ( Position > 0 && ShowAsk ) || New_Record )
  425.     {
  426.         sm("         wOULD yOU lIKE tO sEE tHE Chat-O-Meter tOP 1o? Y/] " , 0 );
  427.         temp[ 0 ] = 0x00;
  428.         hk( temp , temp );
  429.         if ( toupper( temp[ 0 ] ) != 'N' )
  430.             sf( bulletin );
  431.         else
  432.             sm( "No" , 1 );
  433.     }
  434. }
  435.  
  436. void SecsToHours( ULONG t , int *hours, int *mins, int *secs )
  437. {
  438.     *hours = ( t / 3600 );
  439.     t -= ( *hours * 3600 );
  440.     *mins  = ( t / 60 );
  441.     t -= ( *mins * 60 );
  442.     *secs  = t;
  443. }
  444.  
  445. void CreateBulletin( FILE *fptr , char *bulletin , BOOL Trunc , BOOL Quiet , BOOL DoToday )
  446. {
  447.     char    temp[ 400 ], month[ 10 ], day[ 10 ] , year[ 10 ];
  448.     int    hours, mins , secs, i;
  449.     int    td_hours , td_mins , td_secs;
  450.     ULONG    tot_secs;
  451.  
  452.     STRPTR    front[] = {    "!" ,    "|" ,    "O" ,    "|" ,    "¦" ,    ":" ,    "¦" ,    "¡" };
  453.     STRPTR    back[]  = {    ":" ,    ":" ,    "¡" ,    "O" ,    "|" ,    "¦" ,    ":" ,    "·" };
  454.     STRPTR   numba[] = { "o1" ,"o2" , "o3" , "o4" , "o5" , "o6" , "o7" , "o8" };
  455.     STRPTR    damonth[] = { "N/A" , "jAN" , "fEB" , "mAR" , "aPR" , "mAY" , "jUN" , "jUL" , "aUG" , "oCT" , "nOV" , "dEC" };
  456.  
  457.     fprintf( fptr , "\014 .                          _  __           /        __  _      ·          .\n-O-_____   ___.___  ___________ //\\___   ·   ______\\  .        \\ _      -O-\n :/  __/__/   |  ¬\\/   _ ¬\\____\\/____/  · /   /  __ ¬\\ -:---------\\/-----. :\n_/   |   ¬\\_  _    \\_  _   \\_  \\/  ¬\\/ /_/   \\/   \\_>cHAT·O·mETER< :\n" );
  458.     fprintf( fptr , "\\_____     /__|     /__|    /___     //_/ / \\_____     /`----------------' ¦\n-:---l____/---l____/---l___//\\-l____/-\\_\\/-------l____/------ ---  --   -  ¡_\n ¦                       __/  \\  ___  ___________  /\\_________    _______  \\/\n .------------------.  \\_    \\/  ¬\\/  __ ¬\\____\\/____/  __ ¬\\___\\____ ¬\\_¦\n" );
  459.     fprintf( fptr , " ¡ :   ·/X mYSTIC!·   :  /     \\/    \\\\____/__ \\/  ¬\\_  \\____/__   \\/  _/:\n :_`---------------- - _/       \\_____/___     /__     /____     /___/    \\_\n \\-  -- --- ---------\\_________/--Stz--\\____/--l____/----\\____/----\\_____/-\n :                                                                         |\n" );
  460.  
  461.     for ( i = 0 ; i <= 7 ; i ++ )
  462.     {
  463.         // Convert the seconds to hours/mins/secs
  464.         SecsToHours( com_ptr->Time[ i ] , &hours , &mins , &secs );
  465.  
  466.         // Convert the seconds to day/month/year
  467.         GetDate( com_ptr->Date[ i ] , day , month , year );
  468.  
  469.         // Put it in the temp var and check for 1 values (no multiple 's' after the words)
  470.         sprintf( temp , " %s   %s. %-20.20s %2.2d hOURS%2.2d mINS aND %2.2d sECS  (%2.2s-%3.3s-%2.2s)   %s\n" , front[ i ] , numba[ i ] , com_ptr->User[ i ] , hours , mins , secs , day , month , year , back[ i ] );
  471.         
  472.         if ( Trunc )
  473.             MultipleOrNot( temp , hours , mins, secs );
  474.  
  475.         // Write it to disk
  476.         fprintf( fptr , temp );
  477.     }
  478.  
  479.     // Convert the seconds to hours/mins/secs
  480.     SecsToHours( com_ptr->Time[ 8 ] , &hours , &mins , &secs );
  481.  
  482.     // Convert the seconds to day/month/year
  483.     GetDate( com_ptr->Date[ 8 ] , day , month , year );
  484.  
  485.     // Put it in the temp var and check for 1 values (no multiple 's' after the words)
  486.     sprintf( temp , "_:   o9. %-20.20s %2.2d hOURS%2.2d mINS aND %2.2d sECS  (%2.2s-%3.3s-%2.2s)   :_\n" , com_ptr->User[ 8 ] , hours , mins , secs , day , month , year );
  487.     if ( Trunc )
  488.     {
  489.         if ( hours == 1 )
  490.             temp[ 67 ] = ' ';
  491.         if ( mins == 1 )
  492.             temp[ 91 ] = ' ';
  493.         if ( secs == 1 )
  494.             temp[ 118 ] = ' ';
  495.     }
  496.  
  497.     // Write it to disk
  498.     fprintf( fptr , temp );
  499.  
  500.     // Convert the seconds to hours/mins/secs
  501.     SecsToHours( com_ptr->Time[ 9 ] , &hours , &mins , &secs );
  502.  
  503.     // Convert the seconds to day/month/year
  504.     GetDate( com_ptr->Date[ 9 ] , day , month , year );
  505.  
  506.     // Put it in the temp var and check for 1 values (no multiple 's' after the words)
  507.     sprintf( temp , "\\:   1o. %-20.20s %2.2d hOURS%2.2d mINS aND %2.2d sECS  (%2.2s-%3.3s-%2.2s)   :/\n" , com_ptr->User[ 9 ] , hours , mins , secs , day , month , year );
  508.  
  509.     if ( Trunc )
  510.     {
  511.         if ( hours == 1 )
  512.             temp[ 62 ] = ' ';
  513.         if ( mins == 1 )
  514.             temp[ 86 ] = ' ';
  515.         if ( secs == 1 )
  516.             temp[ 113 ] = ' ';
  517.     }
  518.  
  519.     // Write it to disk
  520.     fprintf( fptr , temp );
  521.  
  522.     fprintf( fptr , " \\                                                                         /\n" );
  523.  
  524.     /* And now finish the bulletin with the footer holding all accumulated
  525.      * data. The total time will be displayed in units of days, hours and
  526.      * minutes because of better clearity.
  527.     *
  528.      * This is where the conversion to days is done. td_hours contains
  529.      * the number of days, td_mins the number of hours and td_secs the
  530.      * number of minutes (I need to change the variable names :) ).
  531.      */
  532.     tot_secs  = com_ptr->TimeChatted;
  533.     hours     = tot_secs / 86400;
  534.     tot_secs -= hours * 86400;
  535.     mins      = tot_secs / 3600;
  536.     tot_secs -= mins * 3600;
  537.     tot_secs /= 60;
  538.     
  539.     /* Convert the record time (secs) to hours, mins and secs */
  540.     SecsToHours( td_ptr -> tt_RecTime , &td_hours , &td_mins , &td_secs );
  541.  
  542.     /* Normally we would extract 1900 from the year to get only the last
  543.      * two decimals of the year ( 1995 -> 95 ), but because CoM might well
  544.      * be used in 2000 and up, we will have to take that into account.
  545.      */
  546.     if ( td_ptr -> tt_RecYear >= 2000 )
  547.         td_ptr -> tt_RecYear -= 100;
  548.  
  549.     fprintf( fptr , " :\\      tOTAL # oF cHATS%-10ld  tOTAL cHAT tIME: %3ldd %2.2ldh %2.2ldm      /:\n-O-\\---------------------------------------------------------------------/-O-\n" , com_ptr->Chats , hours, mins , tot_secs );
  550.     if ( ! Quiet )
  551.     {
  552.         if ( ! DoToday )
  553.             fprintf( fptr , " :  ·                                                                   ·  :\n" );
  554.         else
  555.         {
  556.             fprintf( fptr , " :  ·          dAY rECORD%2.2d:%2.2d:%2.2d oN %2.2d-%3.3s-%2.2d (%3d cHATS)            ·  :\n" ,
  557.                 td_hours,
  558.                 td_mins,
  559.                 td_secs,
  560.                 td_ptr -> tt_RecDay,
  561.                 damonth[ td_ptr -> tt_RecMonth ],
  562.                 td_ptr -> tt_RecYear - 1900,
  563.                 td_ptr -> tt_RecChats );
  564.         }
  565.     }
  566.     else
  567.     {
  568.         if ( ! DoToday )
  569.             fprintf( fptr , " :  ·                    (c) 1995 by KiLLraVeN/MYSTiC!                  ·  :\n" );
  570.         else
  571.         {
  572.             fprintf( fptr , " :  · dAY rECORD%2.2d:%2.2d:%2.2d oN %2.2d-%3.3s-%2.2ld (%3d cHATS(cKiLLraVeN/MST ·  :\n",
  573.                 td_hours,
  574.                 td_mins,
  575.                 td_secs,
  576.                 td_ptr -> tt_RecDay,
  577.                 damonth[ td_ptr -> tt_RecMonth ],
  578.                 td_ptr -> tt_RecYear - 1900,
  579.                 td_ptr -> tt_RecChats );
  580.         }
  581.     }
  582.     fclose( fptr );
  583. }
  584.  
  585. void MultipleOrNot( char *temp , int hours , int mins , int secs )
  586. {
  587.     if ( hours == 1 )
  588.         temp[ 57 ] = ' ';
  589.  
  590.     if ( mins == 1 )
  591.         temp[ 81 ] = ' ';
  592.  
  593.     if ( secs == 1 )
  594.         temp[ 108 ] = ' ';
  595. }
  596.  
  597. void GetDate ( ULONG    t , char *day , char *month , char *year )
  598. {
  599.     char    temp[ 30 ];
  600.  
  601.     if ( t > 0 )
  602.     {
  603.         strcpy( temp , ctime( (time_t *) &t) );
  604.         strupr( temp );
  605.  
  606.         temp[ 4 ] += 32; // First letter of the month is now small capital
  607.  
  608.         // WED dEC 21 21:15:40 1994
  609.  
  610.         sprintf( day , "%c%c\0" , temp[ 8 ] , temp[ 9 ] );
  611.         sprintf( month , "%c%c%c\0" , temp[ 4 ] , temp[ 5 ] , temp[ 6 ] );
  612.         sprintf( year , "%c%c\0" , temp[ 22 ] , temp[ 23 ] );
  613.  
  614.     }
  615.     else
  616.     {
  617.         strcpy( day , "--" );
  618.         strcpy( month, "---" );
  619.         strcpy( year , "--" );
  620.     }
  621. }
  622.